package code;

/**
 * @author chenjf
 * @date 2020-11-20
 */
public class Solution1470 {

  public static void main(String[] args) {
    int[] nums = new int[]{1,2,3,4,4,3,2,1};
    int n = 4;
    nums = shuffle(nums, n);
    System.out.println(nums);
  }

  public static int[] shuffle(int[] nums, int n) {
    int[] result = new int[nums.length];
    for(int i = 0, j = 0; i < nums.length && n < nums.length; j++, n++){
      result[i] = nums[j];
      result[i + 1] = nums[n];
      i = i + 2;
    }
    return result;
  }
}
